package com.ruoyi.web.controller.laiqianba.member;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.MemberElementConfigInfo;
import com.ruoyi.member.service.IMemberElementConfigInfoService;
import com.ruoyi.web.wrapper.MemberElementConfigInfoWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 三要素配置Controller
 * 
 * @author ruoyi
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/member/elementConfig")
public class MemberElementConfigInfoController extends BaseController
{
    @Autowired
    private IMemberElementConfigInfoService memberElementConfigInfoService;

    /**
     * 查询三要素配置列表
     */
    @PreAuthorize("@ss.hasPermi('member:elementConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(MemberElementConfigInfo memberElementConfigInfo)
    {
        startPage();
        List<Map<String, Object>> list = memberElementConfigInfoService.selectMemberElementConfigInfoMapList(memberElementConfigInfo);
        list = new MemberElementConfigInfoWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出三要素配置列表
     */
    @PreAuthorize("@ss.hasPermi('member:elementConfig:export')")
    @Log(title = "三要素配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MemberElementConfigInfo memberElementConfigInfo)
    {
        List<MemberElementConfigInfo> list = memberElementConfigInfoService.selectMemberElementConfigInfoList(memberElementConfigInfo);
        ExcelUtil<MemberElementConfigInfo> util = new ExcelUtil<MemberElementConfigInfo>(MemberElementConfigInfo.class);
        util.exportExcel(response, list, "三要素配置数据");
    }

    /**
     * 获取三要素配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('member:elementConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(memberElementConfigInfoService.selectMemberElementConfigInfoById(id));
    }

    /**
     * 新增三要素配置
     */
    @PreAuthorize("@ss.hasPermi('member:elementConfig:add')")
    @Log(title = "三要素配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MemberElementConfigInfo memberElementConfigInfo)
    {
        return toAjax(memberElementConfigInfoService.insertMemberElementConfigInfo(memberElementConfigInfo));
    }

    /**
     * 修改三要素配置
     */
    @PreAuthorize("@ss.hasPermi('member:elementConfig:edit')")
    @Log(title = "三要素配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MemberElementConfigInfo memberElementConfigInfo)
    {
        return toAjax(memberElementConfigInfoService.updateMemberElementConfigInfo(memberElementConfigInfo));
    }

    /**
     * 删除三要素配置
     */
    @PreAuthorize("@ss.hasPermi('member:elementConfig:remove')")
    @Log(title = "三要素配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(memberElementConfigInfoService.deleteMemberElementConfigInfoByIds(ids));
    }
}
